package com.swpu.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swpu.project.common.BaseResponse;
import com.swpu.project.mapper.MineralMapper;
import com.swpu.project.model.entity.Mineral;
import com.swpu.project.service.IMineralService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.swpu.project.util.AuthorityUtil.checkAuthority;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author swpuyanxiegroup1
 * @since 2024-07-29
 */
@Service
public class MineralServiceImpl extends ServiceImpl<MineralMapper, Mineral> implements IMineralService
{

    @Override
    public BaseResponse queryData(String belongId)
    {
        List<Mineral> list = lambdaQuery().eq(Mineral::getBelong, belongId).
                select(Mineral::getDataId,Mineral::getData,Mineral::getName).
                list();


        return BaseResponse.ok(list);

    }

    @Override
    public BaseResponse updateMineral(List<Mineral> minerals,String blockNum)
    {
         if(!checkAuthority(blockNum))
             return BaseResponse.fail("您无权进行该操作或数据填写有误");




//        return BaseResponse.iFSuccess(updateBatchById(minerals));
        return BaseResponse.iFSuccess(saveOrUpdateBatch(minerals));

   }

    @Override
    public BaseResponse deleteMineral(List<Mineral> minerals, String blockNum) {
        return null;

    }


    /*
   *   权限校验,只能更改有权限的区的数据
   *
   * */




}
